package com.steven.io;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class CopyMp3 {
	public static void main(String[] args) throws Exception {
		
		long start =System.currentTimeMillis();
		copy2();
		long end =System.currentTimeMillis();
		
		System.out.println(end-start +"毫秒");
		
	}
	public static void copy1(){
		BufferedInputStream bis=null;
		BufferedOutputStream bos=null;
		
		try {
			  bis = new BufferedInputStream(new FileInputStream("c:/1.mp3"));
			  bos = new BufferedOutputStream(new FileOutputStream("c:/22.mp3"));
			  int b = 0;
			  try {
				while((b=bis.read())!=-1){
					  bos.write(b);
					  
				  }
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}finally{
				try {
					bis.close();
					bos.close();
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				
			}
			  
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	
		
		
	}
	public static void copy2() throws Exception{
		MyBufferedInputStream bis=null;
		BufferedOutputStream bos=null;
		
		try {
			  bis = new MyBufferedInputStream(new FileInputStream("c:/1.mp3"));
			  bos = new BufferedOutputStream(new FileOutputStream("c:/222.mp3"));
			  int b = 0;
			  try {
				while((b=bis.myRead())!=-1){
					  bos.write(b);
					  
				  }
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}finally{
				try {
					bis.myClose();
					bos.close();
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				
			}
			  
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	
		
		
	}


}
